'use strict';

angular.module('ProduceWork').controller('CompletePlanController',
    ['$scope', '$stateParams', 'BaseModule', 'BaseFunction', 'ProduceWorkEnum', '$location', 'Authentication',
    function($scope, $stateParams, BaseModule, BaseFunction, ProduceWorkEnum, $location, Authentication) {
        $scope.StatusEnum = BaseFunction.getEnum('ProduceWorkEnum.CompletePlanStatus');

        $scope.btnSave = function(){
            if($scope.Module.CompletePlan.FocusedRecord.CompleteTime === undefined || 
                $scope.Module.CompletePlan.FocusedRecord.CompleteTime === null){
                BaseFunction.alert("请录入完工日期", "保存提示");
                return;
            }

            $scope.Module.CompletePlan.save();
        };
        $scope.btnCancel = function(){
            $scope.Module.CompletePlan.cancel();            
        };
        $scope.btnList = function(){
            $location.url('/index/CompletePlan/List');
        };

        //初始化
        BaseModule.initModule($scope, 'CompletePlan');
        $scope.Module.CompletePlan.Populate = {path: 'ItemMaster', select: 'Code Name'};

        if($stateParams.id) {
            $scope.Module.CompletePlan.findById($stateParams.id, function(record){
                $scope.Module.CompletePlan.FocusedRecord = record;
            });
        }
    }
]);
